<!--
 * @Author: wanggang
 * @Date: 2019-08-01 09:16:30
 * @Description: 
 -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .main {
            display: flex;
            position: absolute;
            width: 25%;
            height: 25%;
            top: 0;
            left: 0;
            background-color: aqua;
            /* flex-direction: row; */
            /* 设置换行 */
            flex-wrap:wrap;
            /* justify-content:space-between */
        }
        .main .child1 {
            width: 50%;
            height: 50%;
            /* 解决border或padding加宽和模型初始高度的问题 */
            box-sizing: border-box; 
            background-color: brown;
            border:0.5px dashed white;
        }

        .inline {
            display: flex;
            position: absolute;
            top: 50%;
            left: 50%;
            width: 400px;
            height: 50px;
            line-height: 50px;
            background-color: aqua;
            justify-content:space-between;
        }
        .pos {
            /* flex的值控制每个div占用的空间占的比例 */
            flex: 2.5;
            text-align: center;
            /* 控制对齐方式 */
            /* padding-left: 10px; */
        }
     
    </style>
</head>
<body>
    <div class="main">
        <div class="child1"></div>
        <div class="child1"></div>
        <div class="child1"></div>
        <div class="child1"></div>
    </div>

    <!-- 用flex实现一行布局 -->
    <div class="inline">
        <div class="pos">测试1</div>
        <div class="pos">测试2</div>
        <div class="pos">测试3</div>
        <div class="pos">测试4</div>
    </div>
</body>
</html>